
{% extends 'tablehead.html' %}
{% block body %}

<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script type="text/javascript">

    $("#checkAll").change(function () {
        $("input:checkbox").prop('checked', $(this).prop("checked"));
    });
    $(document).ready(function() {
        $("button").click(function(){
            var scan_id = ['a7af5b68-b661-45ad-90fd-ffa27526cdce'];
            $.each($("input[name='del_scan_id']:checked"), function(){
                scan_id.push($(this).val());
            });

            var json_scanid = scan_id.join(", ");
            $.ajax({
                type:'POST',
                <!--contentType: 'application/json; charset=utf-8',-->
                url:'/tools/nmap_del/',
                data:{
                   scan_id: json_scanid,
                   csrfmiddlewaretoken:$('input[name=csrfmiddlewaretoken]').val()
                },
                sucess:function(){

                }
            });
            setTimeout(function(){location.reload();},1000);
        });

    });




</script>

<div id="content">
    <div id="content-header">
        <div id="breadcrumb"><a href="/" title="Go to Home" class="tip-bottom"><i class="icon-home"></i> Home</a> <a
                href="#" class="current">nmap List</a></div>

        <h1>nmap Scans Result</h1>
    </div>

    <div class="container-fluid">
        <hr>
        <div class="span3 offset6">
            {% if messages %}

            {% for message in messages %}
            <div class="alert alert-success alert-block"><a class="close" data-dismiss="alert"
                                                            href="#">×</a>
                <p class="alert-heading">{{ message }}</p>
            </div>
            {% endfor %}

            {% endif %}
        </div>
        <div class="row-fluid">
            <div class="span12">
                <div class="widget-box">
                    <div class="widget-title"><span class="icon"><i class="icon-th"></i></span>
                        <h5>nmap Scan List</h5>
                        <div class="buttons">
                            <button type="button" class="btn btn-danger btn-mini" onclick="">Delete Selected</button>
                        </div>
                    </div>
                    <div class="widget-content nopadding">
                        <table class="table table-bordered data-table">
                            <thead>
                            <tr>
                                <th><p><label><input type="checkbox" id="checkAll"/></label></p></th>
                                <th>URL</th>
                                <th>Port</th>
                                <th>state</th>
                                <th>version</th>
                                <th>Service</th>
                                <th>osfamily</th>
                                <th>osgen</th>
                                <th>cpe</th>
                                <th>Action</th>
                            </tr>
                            </thead>
                            <tbody>{% for data in all_nmap %}
                            <tr data-target="#">
                                <td>
                                    <form>
                                        <label><input type="checkbox" value="{{data.scan_id}}" name="del_scan_id"
                                                      onClick="reload">

                                        </label>
                                    </form>
                                </td>
                                <td><a href="#">{{ data.ip_address }}</a>
                                </td>
                                <td>{{data.port}}</td>
                                <td>{{data.state}}</td>
                                <td>{{data.version}}</td>
                                <td>{{data.name}}</td>
                                <td>{{data.osfamily}}</td>
                                <td>{{data.osgen}}</td>
                                <td>{{data.cpe}}</td>
                                <td>
                                    <form action="/tools/nmap_del/" method="post" class="forms-sample">

                                        {% csrf_token %}
                                        <input type="hidden" name="scan_id" value="{{data.scan_id}}"/>
                                        <button class="btn btn-danger"><i class="icon-remove"></i></button>
                                    </form>
                                </td>
                            </tr>
                            {% endfor %}
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}